<?php

	if (isset($_POST['logout'])) {
		setcookie("logged", 0, time()+60*60*24*100, "/");
	}
	
	if ($_COOKIE['logged'] && !isset($_POST['logout'])){
		echo "<META HTTP-EQUIV='Refresh' CONTENT='2; URL=app.php'>";
	}
	else{	
		
		//login
		echo "<h1>Login</h1>";
		echo "<form action='app.php' method='post'>";
		echo "Username: <input type='text' name='username'><br />";
		echo "Password: <input type='password' name='password'><br />";
		echo "<input type='submit' name='login' value='Log in'/>";
		echo "</form>";
		
		//register
		echo "<h1>Register</h1>";
		echo "<form action='app.php' method='post'>";
		echo "Username: <input type='text' name='username'><br />";
		echo "Email: <input type='text' name='email'><br />";
		echo "Password: <input type='password' name='password'><br />";
		echo "Confirm Password: <input type='password' name='password2'><br />";
		echo "<input type='submit' name='register' value='Register'/>";
		echo "</form>";
	}

?>